
package chapter1.JavaObject.src.com.kkb.tz.bean;



import chapter1.deepCopy.src.com.kkb.tz.test.Person;

public class Man extends Person {

	private String sex;

	public Man(String name, int age, String sex) {
		super(name, age);
		this.sex = sex;
	}

	@Override
	public boolean equals(Object obj) {
		if (!super.equals(obj)) {
			return false;
		}
		if (obj == null || !(obj instanceof Man)) {// 对象为空或者不是Person类的实例
			return false;
		}
		Man man = (Man) obj;
		return sex.equals(man.sex);
	}




	@Override
	public String toString() {
		return "Man{" +
				"sex='" + sex + '\'' +
				", name='" + name + '\'' +
				", age=" + age +
				", address=" + address +
				'}';
	}

	public static void main(String[] args) {
		Person p = new Person("Tom", 22);
		Man m = new Man("Tom", 22, "男");

		/*
		* Condition 'p instanceof Object' is always 'true' less... (Ctrl+F1)
		Inspection info: This inspection analyzes method control and data flow to report possible conditions that are always true or false,
		expressions whose value is statically proven to be constant, and situations that can lead to nullability contract violations.
		Variables, method parameters and return values marked as @Nullable or @NotNull are treated as nullable (or not-null, respectively)
		and used during the analysis to check nullability contracts, e.g. report NullPointerException (NPE) errors that might be produced.
		More complex contracts can be defined using @Contract annotation, for example:
		@Contract("_, null -> null") — method returns null if its second argument is null
		@Contract("_, null -> null; _, !null -> !null") — method returns null if its second argument is null and not-null otherwise
		@Contract("true -> fail") — a typical assertFalse method which throws an exception if true is passed to it
		The inspection can be configured to use custom @Nullable
		@NotNull annotations (by default the ones from annotations.jar will be used)
		*
		* */
		System.out.println(p instanceof  Object);


		System.out.println("p.equals(m):"+p.equals(m));// true
		System.out.println("m.equals(p):"+m.equals(p));// false
	}
}
